package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"net/http"
	"strconv"
)

var id = flag.String("i", "3_benchmark_data_nmdl_550655_object448", "obj id which want to get hash from fabric")

func ReadFromOtherClusters(IP string, port int, obj string) []byte {
	url := "http://" + IP + ":" + strconv.Itoa(port) + "/get?ID=" + obj
	fmt.Println(url)
	resp, err := http.Get(url)
	if err != nil {
		return nil
	}
	defer resp.Body.Close()
	ret, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil
	}
	return ret
}

func main() {
	flag.Parse()
	IP := "10.10.9.20"
	port := 8080

	hash := ReadFromOtherClusters(IP, port, *id)
	fmt.Printf("hash length: %d\n", len(hash))
	fmt.Println(hash)
}
